<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>客户运费排行</el-breadcrumb-item>
    </el-breadcrumb>
    <div style="margin: 10px">
      <el-input style="width: 200px" placeholder="年"  v-model="year" suffix-icon="el-icon-search"></el-input>
      <el-input style="width: 200px;margin-left: 8px"  v-model="month" placeholder="月" suffix-icon="el-icon-search" ></el-input>
      <el-button type="primary" style="margin-left: 8px"  @click="search"> <i class="el-icon-search" style="margin-right: 5px"> </i>搜索 </el-button>
      <router-link to="/total/bar" tag="span"><el-button type="primary" style="margin-left: 8px" >图表展示</el-button></router-link>
      <i class="el-icon-s-data" style="margin-left: 500px"></i>
      <i class="el-icon-s-claim" style="margin-left: 10px"></i>
      <i class="el-icon-s-check" style="margin-left: 10px"></i>
      <i class="el-icon-menu" style="margin-left: 10px"></i>
    </div>
    <el-table :data="pageInFo.list" border stripe >
      <el-table-column type="selection" width="55" align="center">
      </el-table-column>
      <el-table-column type="index" width="60" label="序号" align="center" >
      </el-table-column>
      <el-table-column prop="name" label="姓名" width="150" align="center" sortable>
      </el-table-column>
      <el-table-column prop="rebates" label="减款" width="150" align="center" sortable>
      </el-table-column>
      <el-table-column prop="prepaidAmount" label="代收货款变更后" width="200" align="center" sortable>
      </el-table-column>
      <el-table-column prop="prepaidAmount" label="预付金额" width="150" align="center" sortable>
      </el-table-column>
      <el-table-column prop="deliveryFare" label="送货费" width="150" align="center" sortable>
      </el-table-column>
      <el-table-column prop="fare" label="运费" width="150" align="center" sortable>
      </el-table-column>
      <el-table-column prop="premium" label="保险费" align="center" sortable>
      </el-table-column>

    </el-table>
    <div style="padding: 10px">
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageInFo.pageNum"
          :page-sizes="[1, 2, 10, 15]"
          :page-size="pageInFo.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageInFo.total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      pageInFo:{},
      currentPage:1,
      pageNum:1,
      year:'',
      month:''
    }
  },
  created() {
    this.show()
  },
  methods:{
    show(){
      if (this.year =='' && this.month ==''){
        this.axios.get("http://localhost:8080/fare/"+this.currentPage+"/" + this.pageNum).then(res=>{
          this.pageInFo = res.data.data
        })
      }else if(this.year !='' && this.month ==''){
        this.axios.get("http://localhost:8080/fare/"+this.currentPage+"/" + this.pageNum +"/" +this.year +"-01-01").then(res=>{
          this.pageInFo = res.data.data
        })
      }else{
        alert("约吗")
        this.axios.get("http://localhost:8080/fare/"+this.currentPage+"/" + this.pageNum +"/" +this.year +"-" +this.month+"-01").then(res=>{
          this.pageInFo = res.data.data
        })
      }

    },
    search(){
      let year = /^(19|20)\d{2}$/
      let month = /^((0?[1-9])|(1[0-2]))$/
      let flag1 = year.test(this.year)
      let flag2 = month.test(this.month)
      if (this.year ==''){
        this.$message.error("请输入年份");
      }else if(!flag1){
        this.$message.error("年份格式错误");
      }else if(this.month !=''){
        if (!flag2){
          this.$message.error("月份格式错误");
        }else {
          this.show()
        }
      }else {
        this.show()
      }
    },
    collapse(){
      this.isCollapse = !this.isCollapse
      if (this.isCollapse){
        this.sideWidth = 64,
            this.collapseBtnClass='el-icon-s-unfold'
        this.isShow=false
      }else{
        this.sideWidth = 200
        this.collapseBtnClass='el-icon-s-fold'
        this.isShow=true
      }
    },
    handleSizeChange(val) {
      this.pageNum = val
      this.show()
    },
    handleCurrentChange(val) {
      this.currentPage = val
      this.show()
    }



  }
};
</script>

<style >

</style>

 
 